// Vanity overriding wisdom.

#include <bits/stdc++.h>

using ll = long long;

namespace FastIO {
	template <typename T> inline T read() { T x = 0, w = 0; char ch = getchar(); while (ch < '0' || ch > '9') w |= (ch == '-'), ch = getchar(); while ('0' <= ch && ch <= '9') x = x * 10 + ch - '0', ch = getchar(); return w ? -x : x; }
	template <typename T> inline void write(T x) { if (x == 0) return; write<T>(x / 10), putchar(x % 10 + '0'); }
	template <typename T> inline void print(T x) { if (x < 0) putchar('-'), x = -x; if (x == 0) putchar('0'); write<T>(x); }
	template <typename T> inline void print(T x, char ed) { print<T>(x), putchar(ed); }
}; using namespace FastIO;

struct Interval {
	int l, r;
	Interval () {}
	Interval (int L, int R) : l(L), r(R) {}
	const bool operator < (const Interval &k) const { return r < k.r; }
};

#define MAXM 100001
int p[MAXM];

void solve() {
	int n = read<int>(), m = read<int>(), L = read<int>(), V = read<int>();
	std::vector<Interval> it;
	for (int i = 1, d, v, a, dx; i <= n; ++i) {
		d = read<int>(), v = read<int>(), a = read<int>();
		if (a > 0) {
			if (v > V) { it.emplace_back(d, L); continue; }
			dx = (V * V - v * v + 2 * a) / (2 * a);
			if (d + dx <= L) it.emplace_back(d + dx, L);
		} else if (a == 0) {
			if (v > V) it.emplace_back(d, L);
		} else {
			if (v <= V) continue;
			dx = (v * v - V * V - 1) / (2 * -a);
			it.emplace_back(d, std::min(d + dx, L));
		}
	} std::sort(it.begin(), it.end());
	for (int i = 1; i <= m; ++i) p[i] = read<int>();
	for (auto k = it.begin(); k != it.end(); ) {
		int pos = std::lower_bound(p + 1, p + m + 1, (*k).l) - p;
		if (pos == m + 1 || p[pos] > (*k).r) k = it.erase(k); else ++k;
	} print<int>(it.size(), ' ');
	int j = 0, ans = 0;
	for (auto k : it) {
		if (p[j] >= k.l) continue;
		while (j < m && p[j + 1] <= k.r) ++j;
		++ans;
	} print<int>(m - ans, '\n');
}

int main() {
	freopen("detect.in", "r", stdin);
	freopen("detect.out", "w", stdout);
	int T = read<int>(); while (T--) solve(); return 0;
}
